<?php

/**
 * taxclass actions.
 *
 * @package    sf_sandbox
 * @subpackage taxclass
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 8507 2008-04-17 17:32:20Z fabien $
 */
class taxclassActions extends sfActions
{
  public function executeIndex()
  {
    $this->tax_classList = TaxClassPeer::doSelect(new Criteria());
  }

  public function executeCreate()
  {
    $this->form = new TaxClassForm();

    $this->setTemplate('edit');
  }

  public function executeEdit($request)
  {
    $this->form = new TaxClassForm(TaxClassPeer::retrieveByPk($request->getParameter('tax_class_id')));
  }

  public function executeUpdate($request)
  {
    $this->forward404Unless($request->isMethod('post'));

    $this->form = new TaxClassForm(TaxClassPeer::retrieveByPk($request->getParameter('tax_class_id')));

    $this->form->bind($request->getParameter('tax_class'));
    if ($this->form->isValid())
    {
      $tax_class = $this->form->save();

      $this->redirect('taxclass/edit?tax_class_id='.$tax_class->getTaxClassId());
    }

    $this->setTemplate('edit');
  }

  public function executeDelete($request)
  {
    $this->forward404Unless($tax_class = TaxClassPeer::retrieveByPk($request->getParameter('tax_class_id')));

    $tax_class->delete();

    $this->redirect('taxclass/index');
  }
}
